package Algorithms.jishi.niuke.huawei;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.lang.StringBuffer;
public class Main {
//    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        String str = in.nextLine();
//        String[] array = str.trim().split(" +");
//        String rege = in.nextLine();
//        String regex = rege.replaceAll("\\.\\*", "[a-z]+").replaceAll("\\*", "+");
//        int count = 0;
//        StringBuffer sb = new StringBuffer();
//        for (String s : array) {
//            try {
//                if(s.matches(regex)) {
//                    sb.append(count).append(',');
//                }
//            } catch (Exception e) {}
//            count++;
//        }
//
//        if(sb.length() > 0) {
//            sb.deleteCharAt(sb.length() - 1);
//            System.out.println(sb.toString());
//        } else {
//            System.out.println("-1");
//        }
//    }

    public static boolean match(String des, String pattern) {
        char[] patternChars = pattern.toCharArray();
        char[] desChars = des.toCharArray();
        char lastChar = '$';
        int count4Pattern = 0;
        int i = 0;
        for (; i < des.length(); i++, count4Pattern++) {
            char patternChar = patternChars[i];
            char desChar = desChars[i];
            if(desChar != '.' && desChar != '*') {
                if(patternChar != desChar) {
                    return false;
                }
                lastChar = desChar;
                count4Pattern++;
            } else if(desChar == '.'){
                lastChar = desChar;
            } else if (desChar == '*') {
                i--;
                count4Pattern--;
                break;
            }
        }
        if(i == desChars.length && count4Pattern == patternChars.length) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        String[] array = str.split(" +");
        String pattern = scanner.nextLine();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; i++) {
            String s = array[i];
            if(match(s, pattern)) {
                sb.append(i).append(',');
            }
        }
        if(sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
            System.out.println(sb.toString());
        } else {
            System.out.println("-1");
        }
    }
}